﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Taste
{
    public static class Errors
    {
        /// <summary>
        /// Handle the error in the specified state, using the error as userdata.
        /// </summary>
        public static Action<IStateError<TState>> HandleIn<TState>(TState errorState)
            where TState : struct
        {
            return error => error.HandleError(errorState, error.Error);
        }

        /// <summary>
        /// Handle the error in the specified state.
        /// </summary>
        public static Action<IStateError<TState>> HandleIn<TState>(TState errorState, object userData)
            where TState : struct
        {
            return error => error.HandleError(errorState, userData);
        }
    }
}
